﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
using System.Windows.Forms;
using DAO;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Base;

namespace QLKS
{
    public partial class frmQuenMK : XtraForm
    {
        public frmQuenMK()
        {
            InitializeComponent();
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            if (!dxValidationProvider1.Validate()) 
                return;
            try
            {
                var login = NguoiDungDAO.Login(txtTenDN.Text,null,txtHoTen.Text);
                if (login.HasRows)
                {
                    login.Read();
                    MessageBox.Show("Mật khẩu người dùng: " + login[1], "Completed", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    Close();
                }
                else
                {
                    MessageBox.Show("Họ tên, hoặc tên đăng nhập không đúng!", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            
            catch (SqlException ex)
            {
                string str = String.Format("Lỗi: {0}", ex.Message);
                MessageBox.Show(str, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}